import { Component, OnInit, Input } from '@angular/core'
import { TranslateService } from '@ngx-translate/core'
import { ManageService } from 'src/app/@core/manage.service'
import { AuthGuardService } from '../../@core/auth-guard-service.guard'

@Component({
  selector: 'app-select-avatar-type',
  templateUrl: './select-avatar-type.component.html',
  styleUrls: ['./select-avatar-type.component.less']
})
export class SelectAvatarTypeComponent implements OnInit {
  i18nValues: any //国际化变量
  radioGroupStyle: any = {
    'margin-bottom': '5px',
    'padding-left': '20px',
    height: 'auto',
    'max-height': '500px'
  }
  avatarType = ''
  avatarTypes = []
  currentOption = {}
  @Input() data: any
  tabActiveId: string | number = 'tab2'
  closeDialog:any

  constructor(
    private translate: TranslateService,
    private authGuardService: AuthGuardService
  ) { }

  ngOnInit(): void {
    this.closeDialog = this.data.closeDialog
    this.i18nValues = this.translate.instant('home')
  }

  changeTab() {
    this.tabActiveId = 'tab1'
  }

  close(isCancel) {
    if (!isCancel && Object.keys(this.currentOption).length === 0) {
      this.authGuardService.showModalPanel('warning', '请先选择藏品类别！')
      return
    }
    this.data.onClose(
      Object.keys(this.currentOption).length ? this.currentOption : '',
      isCancel
    )
  }
}
